{% extends "base.html" %}

{% block title %}漏洞详情{% endblock %}

{% block css %}

{% endblock %}

{% block body %}
                        <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">URL漏洞详情
                                <button type="button" class="btn btn-primary"onclick="location.reload();">刷新</button>
                        </div>
                    <!-- 结果 -->
                        <div class="panel-body">
                        <!--检索模块 -->
                        <!-- 展示模块 -->
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                    <tr>
                                        <th>漏洞URL</th>
                                        <th>漏洞类型</th>
                                        <th>添加时间</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    {% for i in data %}
                                        <tr class="accordion-toggle" data-target="#details-{{ i.id }}" data-toggle="collapse">
                                            <td><a href="{{ i.url }}">{{ i.url }}</a></td>
                                            <td>{{ i.vulntype }}</td>
                                            <td>{{ i.time }}</td>
                                        </tr>

          <!-- 展开折叠部分 -->
          <tr>
            <td colspan="3" class="hiddenRow">
              <div id="details-{{ i.id }}" class="accordian-body collapse">
                <table class="table table-striped table-condensed table-bordered">
                  <tbody>
                    <tr>
                      <td>URL</td>
                      <td>{{ i.url }}</td>
                    </tr>
                      <tr>
                      <td>ParamKey</td>
                      <td>{{ i.param }}</td>
                    </tr>
                    <tr>
                      <td><strong>payload</strong></td>
                      <td>{{ i.payload }}</td>
                    </tr>
                    {% set snapshot=i.snapshot|my_eval %}
                    {% for item in snapshot %}
                    <tr>
                      <td><strong>request{{ loop.index }}</strong></td>
                     <td style="white-space: pre-line;">{{ item[0] }}</td>
                    </tr>
                     <tr>
                      <td><strong>Response{{ loop.index }}</strong></td>
                      <td style="white-space: pre-line;">{{ item[1] }}</td>
                    </tr>

                    {% endfor %}

                  </tbody>
                </table>
              </div>
            </td>
          </tr>
        </tbody>
          {% endfor %}
   </table>
                                    </tbody>
    </div>

                        <!-- 分页模块 -->
                        <div>
  <nav class="mt-4">
    <ul class="pagination justify-content-center">
      {% if page > 1 %}
        <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=page - 1, url=url) }}">上一页</a></li>
      {% else %}
        <li class="page-item disabled"><span class="page-link">上一页</span></li>
      {% endif %}

      {% if total_pages <= 7 %}
        {% for p in range(1, total_pages + 1) %}
          {% if p == page %}
            <li class="page-item active"><a class="page-link" href="#">{{ p }}</a></li>
          {% else %}
            <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=p, url=url) }}">{{ p }}</a></li>
          {% endif %}
        {% endfor %}
      {% else %}
        {% if page <= 4 %}
          {% for p in range(1, 6) %}
            {% if p == page %}
              <li class="page-item active"><a class="page-link" href="#">{{ p }}</a></li>
            {% else %}
              <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=p, url=url) }}">{{ p }}</a></li>
            {% endif %}
          {% endfor %}
          <li class="page-item disabled"><span class="page-link">...</span></li>
          <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=total_pages, url=url) }}">{{ total_pages }}</a></li>
        {% elif page >= total_pages - 3 %}
          <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=1, url=url) }}">1</a></li>
          <li class="page-item disabled"><span class="page-link">...</span></li>
          {% for p in range(total_pages - 4, total_pages + 1) %}
            {% if p == page %}
              <li class="page-item active"><a class="page-link" href="#">{{ p }}</a></li>
            {% else %}
              <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=p, url=url) }}">{{ p }}</a></li>
            {% endif %}
          {% endfor %}
        {% else %}
          <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=1, url=url) }}">1</a></li>
          <li class="page-item disabled"><span class="page-link">...</span></li>
          {% for p in range(page - 2, page + 3) %}
            {% if p == page %}
              <li class="page-item active"><a class="page-link" href="#">{{ p }}</a></li>
            {% else %}
              <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=p, url=url) }}">{{ p }}</a></li>
            {% endif %}
          {% endfor %}
          <li class="page-item disabled"><span class="page-link">...</span></li>
          <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=total_pages, url=url) }}">{{ total_pages }}</a></li>
        {% endif %}
      {% endif %}

      {% if page < total_pages %}
        <li class="page-item"><a class="page-link" href="{{ url_for('vulnscan.showInformation', page=page + 1, url=url) }}">下一页</a></li>
      {% else %}
        <li class="page-item disabled"><span class="page-link">下一页</span></li>
      {% endif %}
    </ul>
  </nav>
</div>
  </div>
</div>


{% endblock %}